<template>
	<view class="my-collect-main">
		<view class="return-title">
			<view class="return-icon" @click="returnPreviewPage">
				<uni-icons type="arrow-left" size="35"></uni-icons>
			</view>
			<view class="title">
				我的收藏
			</view>
		</view>

		<view class="user-collect-container">
			<UserCollectVue :notes="notes" :goods="goods"></UserCollectVue>
		</view>

	</view>
</template>

<script>
	import UserCollectVue from '../../../../components/common-components/UserCollect.vue';
	import {
		getCollectList
	} from '@/request/user.js';
	import mitter from '@/common/mitt/eventBus.js';
	export default {
		components: {
			UserCollectVue
		},
		data() {
			return {
				notes: [
					// {
					// 	noteAid: 1,
					// 	isVedio: false,
					// 	url: 'https://img2.baidu.com/it/u=868566590,1876533926&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1139',
					// 	title: '今天很忧郁',
					// 	authorAvatar: 'https://img2.baidu.com/it/u=3768926381,2413212543&fm=253&fmt=auto&app=138&f=JPEG?w=475&h=475',
					// 	authorUserName: '小王子',
					// 	isLike: false, // 是否点赞
					// 	likeCount: 0,
					// },
					// {
					// 	noteAid: 2,
					// 	isVedio: true,
					// 	url: 'https://fzg-jy.oss-cn-hangzhou.aliyuncs.com/jyapp/home/yufen/camping/video/%E5%85%85%E6%B0%94%E6%B2%99%E5%8F%915.mp4',
					// 	videoCover: 'https://img0.baidu.com/it/u=195508433,693019668&fm=253&fmt=auto&app=120&f=JPEG?w=750&h=500',
					// 	title: '家人们找到一个露营圣地',
					// 	authorAvatar: 'https://img2.baidu.com/it/u=4098516808,3262658970&fm=253&fmt=auto&app=138&f=JPEG?w=380&h=380',
					// 	authorUserName: '甜心草莓',
					// 	isLike: true, // 是否点赞
					// 	likeCount: 235,
					// }
				],
				goods: [
					// {
					// 	goodsAid: 1,
					// 	goodImg: 'https://pic.rmb.bdstatic.com/bjh/down/df5f0542d63eea8657ac42f05b50f5db.jpeg',
					// 	goodsName: '帐篷',
					// 	goodsPrice: '￥233'
					// },
				],
			};
		},

		onLoad(options) {
			// console.log(options);
			// 获取收藏列表
			this.getCollectListFunc(options.userAid);
		},

		methods: {

			// 获取收藏列表
			getCollectListFunc(userAid) {
				this.notes = [];
				this.goods = [];
				uni.showLoading({
					title: '加载中...',
				})
				getCollectList({
					userAid
				}).then(res => {
					// console.log(res);
					setTimeout(() => {
						this.notes = res.data.data.notes;
						this.goods = res.data.data.goods;
						mitter.emit("searchNoteOrCollectResult",{notes: this.notes, goods: this.goods})
						uni.hideLoading();
					}, 800)
				}).catch(err=>{
					console.error(err)
					uni.showToast({
						title: '获取数据失败，请稍后再试...',
						icon: 'none'
					})
					uni.hideLoading();
				})
			},

			returnPreviewPage() {
				uni.navigateBack()
			},
		},
	};
</script>

<style lang="scss" scoped>
	.my-collect-main {
		.return-title {
			width: 90%;
			margin-top: 60rpx;
			text-align: center;
			margin-left: auto;
			margin-right: auto;

			.return-icon {
				float: left;
			}

			.title {
				font-size: 40rpx;
				margin-right: 20rpx;
			}
		}

		.user-collect-container {
			width: 90%;
			margin-left: auto;
			margin-right: auto;
		}
	}
</style>